package dice.sinanya.tools.checkdata;

import dice.sinanya.entity.imal.AlgorithmTypes;

import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;

import static dice.sinanya.tools.makedata.RandomInt.*;

public class DataMake {
    public HashMap<Integer, Integer> getData(int times, AlgorithmTypes algorithmTypes) {
        HashMap<Integer, Integer> result = new HashMap<>();

        for (int i = 1; i <= 100; i++) {
            result.put(i, 0);
        }

        for (int i = 1; i <= times; i++) {
            int ran;
            switch (algorithmTypes) {
                case Expect:
                    ran = randomExpect(1, 100);
                    break;
                case Mersenne:
                    ran = randomMersenne(1, 100);
                    break;
                case Default:
                    ran = randomDefault(1, 100);
                    break;
                default:
                    ran = random(1, 100);
            }
            result.put(ran, result.get(ran) + 1);
        }

        return result;
    }

    public void write(String fileName, String text) {
        try (FileWriter writer = new FileWriter(fileName, true)) {
            writer.write(text);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}